<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>

	<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="Keywords" content="中软国际-微信公众号管理后台">
        <meta name="Description" content="中软国际-微信公众号管理后台">
        <link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
		<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
		<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
		<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>	
		
		<style type="text/css">
		.dropdown-submenu:hover>.dropdown-menu{display:none}
		.td1{
			width:15%;
			height:37px;
			text-align:right;
			padding-right:6px;
		}
		.rightTd{
			width:80%;
			height:37px;
			text-align:left;
			padding-left:6px;
		}
		.inputr{
			min-width:16%;
			min-height:26px;
		}
		</style>
		
		<title>微信公众号管理后台</title>
        
        <script type="text/javascript">
        	//保存，提交form表单
        	function _checkCarNoExist(obj){
        		var carNo= obj.value;
        		$.ajax({
			 		type:"GET",
					url:"<%=path%>/vehicleInfo/checkCarNoExist.do",
					data: {
						carNo : carNo
					},
					dataType:"json",
					async : false, //同步执行
					success:function(data){
						console.info(data);
						if(data.success){
						} else {
							parent.swal("OMG", data.msg, "error");
							obj.value = "";
						}
					}
				})
        	}
        	
			function submitForm(){
				var flag = checkInfo();
				if(flag){
					var url = "<%=path%>/vehicleInfo/saveVehicle";
					fm.action=url;
					fm.submit();
				}
			}
			//验证输入是否符合规范
			function checkInfo(){
				var carName = $("#carName").val();
				carName = $.trim(carName);// 去除收尾空格
				if(carName == ''){
				    parent.layer.alert("车辆名称不能为空!");
					return false;
				}
				
				var carNo = $("#carNo").val();
				carNo = $.trim(carNo);// 去除收尾空格
				if(carNo == ''){
					parent.layer.alert("车牌号码不能为空!");
					return false;
				}
				
				var carColor = $("#carColor").val();
				carColor = $.trim(carColor);// 去除收尾空格
				if(carColor == ''){
					parent.layer.alert("车辆颜色不能为空!");
					return false;
				}
				
				var sortNum = $("#sortNum").val();
				var re =/^[1-9]+[0-9]*]*$/;
				sortNum = $.trim(sortNum);// 去除收尾空格
				if(sortNum == ''){
					parent.layer.alert("排序号不能为空!");
					return false;
				}else if (!re.test(sortNum)){
					parent.layer.alert("排序号必须为有效整数");
					$("#sortNum").val("");
					return false;
				}
				return true;
			}
			
		</script>
	</head>
	<body class="theme-blue" data-theme="theme-blue">
    	<div id="contentDiv" style="padding: 4px;width:99%;" >
			<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
				<div class="toptil"><c:if test="${operat == 'add'}">添加</c:if><c:if test="${operat == 'edit'}">编辑</c:if>车辆信息</div>
			</div>
			<form id="fm" name="fm" class="form-horizontal" method="post"  novalidate="novalidate">
				<input type='hidden' id='operat' name='operat' value="${operat}" />
				<input type='hidden' id='carUuid' name='carUuid' value="${vehicleMap.CAR_UUID }" />
				<div style="width:100%;margin-top:20px;margin-left:10px;">
					<table style="width:100%;"  >
						<tr>
							<td class="td1" nowrap>车辆名称：</td>
							<td class="rightTd" nowrap>
								<input id="carName" class="inputr" name="carName" value="${vehicleMap.CAR_NAME }" type="text" data-rule-required="true">
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>车牌号码：</td>
							<td class="rightTd" nowrap>
							<input id="carNo" class="inputr" name="carNo"  value="${vehicleMap.CAR_NO }" type="text" onchange="_checkCarNoExist(this)" data-rule-required="true"data-rule-number="true">	
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>车辆颜色：</td>
							<td class="rightTd" nowrap>
							<input id="carColor" class="inputr" name="carColor" value="${vehicleMap.CAR_COLOR}" type="text" data-rule-required="true"data-rule-number="true">	
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>排序号：</td>
							<td class="rightTd" nowrap>
							<input id="sortNum" class="inputr" name="sortNum" value="${vehicleMap.SORT_NUM}" type="text" data-rule-required="true"data-rule-number="true">	
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap></td>
							<td class="rightTd" nowrap>
								<div class="form-actions">
									<a onclick="submitForm();" class="btn btn-primary">保存</a>
									<a onclick="window.history.go(-1);" class="btn">取消</a>
								</div>
							</td>
							
						</tr>
					</table>
				</div>
			</form>
		</div>
	</body>
	<script type="text/javascript">
  	$(document).ready(function(){
		_reHeight();
	});
	function _reHeight(){
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height();
		main.height(mainheight);
	}
	</script>
</html>